<?php

/**
 * {{traitNamePrefix}}StringUtils{{traitNameSuffix}}Test
 *
 * PHP version 7.1
 *
 * @package {{invokerPackage}}
 * @author  OpenAPI Generator team
 * @link    https://github.com/openapitools/openapi-generator
 */

/**{{#apiInfo}}{{#appName}}
 * {{{appName}}}
 *
 {{/appName}}
 {{#appDescription}}
 * {{{appDescription}}}
 {{/appDescription}}
 {{#version}}
 * The version of the OpenAPI document: {{{version}}}
 {{/version}}
 {{#infoEmail}}
 * Contact: {{{infoEmail}}}
 {{/infoEmail}}
 * Generated by: https://github.com/openapitools/openapi-generator.git
 */

/**
 * NOTE: This class is auto generated by the openapi generator program.
 * https://github.com/openapitools/openapi-generator
 * Do not edit the class manually.
 */
namespace {{utilsPackage}};

use {{utilsPackage}}\{{traitNamePrefix}}StringUtils{{traitNameSuffix}} as StringUtils;
use PHPUnit\Framework\TestCase;

/**
 * {{traitNamePrefix}}StringUtils{{traitNameSuffix}}Test Class Doc Comment
 *
 * @package {{utilsPackage}}
 * @author  OpenAPI Generator team
 * @link    https://github.com/openapitools/openapi-generator
 * @coversDefaultClass \{{utilsPackage}}\{{traitNamePrefix}}StringUtils{{traitNameSuffix}}
 */
class {{traitNamePrefix}}StringUtils{{traitNameSuffix}}Test extends TestCase
{
    /**
     * @covers ::camelize
     * @dataProvider provideWordsForCamelizeTest
     */
    public function testCamelize($word, $lowercaseFirstLetter, $expectedWord)
    {
        $this->assertSame($expectedWord, StringUtils::camelize($word, $lowercaseFirstLetter));
    }

    public function provideWordsForCamelizeTest()
    {
        return [
            // fixtures from modules/openapi-generator/src/test/java/org/openapitools/codegen/utils/StringUtilsTest.java
            ['openApiServer/model/pet', null, 'OpenApiServerModelPet'],
            ['abcd', null, 'Abcd'],
            ['some-value', null, 'SomeValue'],
            ['some-Value', null, 'SomeValue'],
            ['some_value', null, 'SomeValue'],
            ['some_Value', null, 'SomeValue'],
            ['$type', null, '$Type'],

            ['abcd', true, 'abcd'],
            ['some-value', true, 'someValue'],
            ['some_value', true, 'someValue'],
            ['Abcd', true, 'abcd'],
            ['$type', true, '$type'],

            ['123', true, '123'],
            ['$123', true, '$123'],
        ];
    }

    /**
     * @covers ::isReservedWord
     * @dataProvider provideWordsForIsReservedTest
     */
    public function testisReservedWord($word, $expected)
    {
        $this->assertSame($expected, StringUtils::isReservedWord($word));
    }

    public function provideWordsForIsReservedTest()
    {
        return [
            ['return', true],
            ['switch', true],
            ['class', true],
            ['interface', true],
            ['ABSTRACT', true],
            ['Trait', true],
            ['final', true],
            ['foobar', false],
            ['DateTime', false],
            ['Pet', false],
            [123, false],
            [null, false],
        ];
    }
}
{{/apiInfo}}
